<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //  扩展运算符  ...
      // 1） 合并数组
      var arr1 = [1, 2, 3]
      var arr2 = [4, 5, 6]
      var arr3 = [...arr2, ...arr1, 7, 8, 9]
      console.log(arr3)
      // 2) 合并对象
      // 扩展运算符 当对象只有一层时和一维数组 是深拷贝，多层时不是

      var obj1 = {
        name: 1,
        age: 2,
        info: {
          sex: '男'
        }
      }

      var obj2 = {
        sex: '男',
        shengao: 188,
        ...obj1
      }

      console.log(obj2)
      obj2.info.sex = '女'
      console.log(obj2.info.sex)
      console.log(obj1.info.sex)
    </script>
  </body>
</html>
